import Service from '@/common/service/service';
import RequestModel from "@/common/model/request.model";
import ResponseModel from '@/common/model/response.model';
import MenuModel from "@/views/system/menu-mgt/model/menu.model";
import SaveMenuModel from "@/views/system/menu-mgt/model/save-menu.model";

/**
 * 菜单管理服务
 */
export default class MenuMgtService {
    /**
     * 获取菜单列表
     */
    public static getMenuList(): Promise<ResponseModel> {
        return Service.get('sys/menu/getSysMenus');
    };

    /**
     * 保存一大票的菜单数据
     */
    public static saveMenu(data: SaveMenuModel): Promise<ResponseModel> {
        return Service.post('sys/menu/saveSysMenusTree', data);
    };

    /**
     * 新增编辑菜单组
     */
    public static saveOrUpdateSysMenu(data: MenuModel): Promise<ResponseModel> {
        return Service.post('sys/menu/saveOrUpdateSysMenu', data);
    };

    /**
     * 菜单图标上传
     */
    public static uploadImage(data): Promise<ResponseModel> {
        return Service.request({
            url: 'sys/menuImage/uploadImage',
            method: 'post',
            data,
        });
    };

    /**
     * 同步菜单
     */
    public static syncMenu(): Promise<ResponseModel> {
        return Service.post('sys/menu/syncServiceMenus');
    };
}
